package apps;

import hypergraph.HyperEdge;
import hypergraph.HyperGraph;
import hypergraph.Node;

import java.awt.Dimension;

import javax.swing.JFrame;


import org.jgap.Genotype;

import edu.uci.ics.jung.algorithms.layout.CircleLayout;
import edu.uci.ics.jung.algorithms.layout.Layout;
import edu.uci.ics.jung.algorithms.layout.SpringLayout;
import edu.uci.ics.jung.visualization.BasicVisualizationServer;

public abstract class GraphViewApp {
	protected Dimension size;
	protected BasicVisualizationServer<Node, HyperEdge> vv;
	protected Layout<Node, HyperEdge> layout;
	protected HyperGraph graph;
	
	public GraphViewApp(){
		size = new Dimension(600, 600);
		setGraph(new HyperGraph());
		initScreen();
	}
	
	private void initScreen() {
		vv = new BasicVisualizationServer<Node, HyperEdge>(layout);
		vv.setPreferredSize(size); //Sets the viewing area size
		JFrame frame = new JFrame("Simple Graph View");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().add(vv);
		frame.pack();
		frame.setVisible(true);	
	}

	public void setGraph(HyperGraph g){
		graph = g;
		layout = new SpringLayout<Node, HyperEdge>(graph.toGraph());
		layout.setSize(size);
		if(vv != null) vv.setGraphLayout(layout);
	}
	public abstract void setLayout();

}
